/***************************************************************************
 *   Copyright (C) 2008 by JBox systems
 *   gabi@shaargiora.co.il
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 ***************************************************************************/

#pragma once

#include <QAbstractItemModel>

#include "modelitems.h"
/**
	Implementation of most common methods required to create a model.
*/
class Model : public QAbstractItemModel {
    Q_OBJECT

	public:
		/**
			Default constructor.
			@param parent Parent for Qt heirarchy and memory management.
		*/
		Model(QObject *parent = 0);
		/**
			Default deconstructor.
		*/
		~Model();

		/**
			Refer to Qt4 docs.
		*/
		QVariant data(const QModelIndex &index, int role) const;
		/**
			Refer to Qt4 docs.
		*/
		Qt::ItemFlags flags(const QModelIndex &index) const;
		/**
			Refer to Qt4 docs.
		*/
		QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
		/**
			Refer to Qt4 docs.
		*/
		QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
		/**
			Refer to Qt4 docs.
		*/
		QModelIndex parent(const QModelIndex &index) const;
		/**
			Refer to Qt4 docs.
		*/
		int rowCount(const QModelIndex &parent = QModelIndex()) const;
		/**
			Refer to Qt4 docs.
		*/
		int columnCount(const QModelIndex &parent = QModelIndex()) const;
		/**
			Refer to Qt4 docs.
		*/
		bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );

		/**
			Clears all selected checkmarks.
		*/
		void clearSelection();

	protected:
		/**
			Top level tree element.
		*/
		ModelItem *rootItem;

	signals:

		/**
			Item checked
		*/
		void itemChecked(void *item);

		/**
			Item unchecked
		*/
		void itemUnChecked(void *item);
};

